<?php

class userAdministration extends bee\form
{ protected static $__formID = "frm2011090960233";
  protected $client;
  protected $filter;
  protected $txtFilter;
  protected  $grid;

	public function createForm($evt)
	{ $this->__caption = "Users overview";
    $this->__version = "1.1";

	  $this->client = new bee\user();
    $this->client->org_id = $this->__app->getClientFilter();

    $this->grid = userGrid::getInstance();
    $this->grid->setDataSource($this->client);
    $this->grid->setColumnProperties(array("name" => "login", "caption" => "Login", "width" => 100));
    $this->grid->setColumnProperties(array("name" => "description", "caption" => "Description", "width" => 300));
    $this->grid->setColumnProperties(array("name" => "last_login_date", "caption" => "Last login", "width" => 150));
    $this->grid->detailFormName="userData";
    $this->grid->showButtons = GRID_SHOW_ALL;
    $this->txtFilter = new bee\text("filter", $this->filter);

	}

	public function grid_filter($evt)
	{ $this->filter = $evt["filter"];
	  $filter = "%" . $this->filter . "%";

    $afWh = new bee\afterWhere(" AND (login like :description1 OR description like :description2)",
                                              array("description1" => $filter, "description2"=> $filter),
                                              array("description1" => PDO::PARAM_STR, "description2" => PDO::PARAM_STR));
    $this->grid->setDataSource($this->client, $afWh);

	}
}

class userGrid extends bee\grid
{ //protected static $__instance;
  public function createGrid($evt)
  { $this->__gridID = "grd201003200029";
    $this->setColumnProperties(array("name" => "login", "caption" => "Login", "width" => 100));
    $this->setColumnProperties(array("name" => "description", "caption" => "Description", "width" => 300));
    $this->setColumnProperties(array("name" => "last_login_date", "caption" => "Last login", "width" => 150));
    $this->detailFormName="userData";
    $this->showButtons = GRID_SHOW_ALL;
    //echo "UCG";
  }
}